Skip to content

[SSF-159] - Automated Emails 1 Implementation#127

Open
dburkhart07 wants to merge 8 commits intomainfrom
ddb/SSF-159-automated-emails
Open

[SSF-159] - Automated Emails 1 Implementation#127
dburkhart07 wants to merge 8 commits intomainfrom
ddb/SSF-159-automated-emails

Conversation

@dburkhart07
Copy link

@dburkhart07 dburkhart07 commented Mar 13, 2026

ℹ️ Issue

Closes #159

📝 Description

  • Created an email template to store an arbitrary amount of parameters to be used in the subject and body
  • Created temporary placeholders for ssf email, as well as base url (both to be later changed when we switch to production)
  • Implemented automated email sending workflows for creating a volunteer, submitting a pantry/fm application, getting a pantry/fm application approved, and submitting a food request
  • Wrote food manufacturer tests

✔️ Verification

BEFORE TESTING: Add 2 new environment variables:

  • AWS_SES_SENDER_EMAIL (set this to one of your emails, this will be the address that sends the emails for you to verify)
  • SEND_AUTOMATED_EMAILS (switch this to true to turn on Cognito account creation and email sending permissions)

Add your email that you put in the AWS_SES_SENDER_EMAIL into the following AWS SES Identities: https://us-east-2.console.aws.amazon.com/ses/home?region=us-east-2#/identities

Tested each workflow to ensure the proper sender, subject, message, attachments were all there.

🏕️ (Optional) Future Work / Notes

Should figure out why this email gets sent to spam by default

@dburkhart07 dburkhart07 marked this pull request as ready for review March 13, 2026 22:29
@Juwang110 Juwang110 self-requested a review March 14, 2026 14:16
@Yurika-Kan Yurika-Kan self-requested a review March 18, 2026 00:44
Copy link
Collaborator

@Yurika-Kan Yurika-Kan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super great pr! super cool to test this & see emails come in as if i am the end user of this site :)

regarding the order of either saving to the db then sending emails and vice versa (specifically in request & user), i'd suggest to save the data first then send the appropriate email in cases that email sending fails. ideally we wouldn't wait for the email sending to succeed before saving that data. db is the source of truth & emails are more so secondary/side effect!

tested via:

  • verified email -> postman -> receiving emails
  • jest tests pass
    thanks for adding all these tests btw!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file name typo: manufaacturers --> manufacturers

bodyHTML: string,
attachments?: EmailAttachment[],
): Promise<unknown> {
if (process.env.SEND_AUTOMATED_EMAILS === 'false') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this env variable is not set, then it would default to sending the emails~ could we treat email sending as enabled only when it is true & everything else (false or nothing/default), ie when it's not true, is disabled?


const message = emailTemplates.pantrySubmitsFoodRequest({
pantryName: pantry.pantryName,
volunteerName: pantry.pantryUser.firstName,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to take in the volunteer name here!

await service.deny(id);

const denied = await service.findOne(id);
expect(denied.status).toBe(ApplicationStatus.DENIED);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we check here that it does not send any email when denying

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add tests for 2 edge cases:

  • email fails before request is saved --> current functionality is that request will not be saved
  • zero volunteers associated with a pantry --> create succeeds, sendEmails succeeds with empty recipient array, request is saved


await service.approve(5);

expect(mockEmailsService.sendEmails).toHaveBeenCalledWith(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also check it as called once

userCognitoSub,
});
return this.repo.save(user);
await this.repo.save(user);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: in requests we send email first then save where as here, we save then send email

i think this design makes more sense

// Send welcome email to new volunteers
if (role === Role.VOLUNTEER) {
const message = emailTemplates.volunteerAccountCreated();
await this.emailsService.sendEmails(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although the await can fail the flow / hang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants